home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / perl5 / YAML / Marshall.pm < prev    next >
Encoding:
Perl POD Document  |  2010-01-02  |  1.4 KB  |  82 lines

  1. package YAML::Marshall;
  2.  
  3. use strict;
  4. use warnings;
  5. use YAML::Node ();
  6.  
  7. our $VERSION = '0.71';
  8.  
  9. sub import {
  10.     my $class = shift;
  11.     no strict 'refs';
  12.     my $package = caller;
  13.     unless (grep { $_ eq $class} @{$package . '::ISA'}) {
  14.         push @{$package . '::ISA'}, $class;
  15.     }
  16.  
  17.     my $tag = shift;
  18.     if ( $tag ) {
  19.         no warnings 'once';
  20.         $YAML::TagClass->{$tag} = $package;
  21.         ${$package . "::YamlTag"} = $tag;
  22.     }
  23. }
  24.  
  25. sub yaml_dump {
  26.     my $self = shift;
  27.     no strict 'refs';
  28.     my $tag = ${ref($self) . "::YamlTag"} || 'perl/' . ref($self);
  29.     $self->yaml_node($self, $tag);
  30. }
  31.  
  32. sub yaml_load {
  33.     my ($class, $node) = @_;
  34.     if (my $ynode = $class->yaml_ynode($node)) {
  35.         $node = $ynode->{NODE};
  36.     }
  37.     bless $node, $class;
  38. }
  39.  
  40. sub yaml_node {
  41.     shift;
  42.     YAML::Node->new(@_);
  43. }
  44.  
  45. sub yaml_ynode {
  46.     shift;
  47.     YAML::Node::ynode(@_);
  48. }
  49.  
  50. 1;
  51.  
  52. __END__
  53.  
  54. =head1 NAME
  55.  
  56. YAML::Marshall - YAML marshalling class you can mixin to your classes
  57.  
  58. =head1 SYNOPSIS
  59.  
  60.     package Bar;
  61.     use Foo -base;
  62.     use YAML::Marshall -mixin;
  63.  
  64. =head1 DESCRIPTION
  65.  
  66. For classes that want to handle their own YAML serialization.
  67.  
  68. =head1 AUTHOR
  69.  
  70. Ingy d├╢t Net <ingy@cpan.org>
  71.  
  72. =head1 COPYRIGHT
  73.  
  74. Copyright (c) 2006. Ingy d├╢t Net. All rights reserved.
  75.  
  76. This program is free software; you can redistribute it and/or modify it
  77. under the same terms as Perl itself.
  78.  
  79. See L<http://www.perl.com/perl/misc/Artistic.html>
  80.  
  81. =cut
  82.